/*
 * Copyright (c) 2013 XDream
 * Copyright (c) 2013 bruceshu <shuhuan.bruce@gmail.com>
 * 2024-9-20
 */


#include "video_decoder.h"

namespace mydecoder {




VideoDecoder::VideoDecoder(/* args */)
{
}

VideoDecoder::~VideoDecoder()
{
    if (m_videoDecodedCallback != nullptr) {
        delete m_videoDecodedCallback;
        m_videoDecodedCallback = nullptr;
    }
}

void VideoDecoder::setOption(std::string key, std::string value)
{
    std::lock_guard<std::mutex> lock(m_optionMutex);
    auto iter = m_options.find(key);
    if (iter != m_options.end()) {
        m_options.erase(iter);
    }

    m_options.emplace(key, value);
}

std::string VideoDecoder::getOption(std::string key)
{
    std::lock_guard<std::mutex> lock(m_optionMutex);
    auto iter = m_options.find(key);
    if (iter != m_options.end()) {
        return iter->second;
    }

    return "";
}

void VideoDecoder::registerDecodedCallback(VideoDecodedCallback *callback)
{
    m_videoDecodedCallback = callback;
}

// VideoDecodedCallback* VideoDecoder::getDecodedCallback()
// {
//     return m_videoDecodedCallback;
// }

    // virtual VideoCodecError init(const AVBuffer *buffer) = 0;
    // virtual VideoCodecError decode() = 0;
    // virtual VideoCodecError registerDecodeCompleteCallback();
    // virtual VideoCodecError flush() = 0;
}

